package com.beiming.sensor

import android.app.Activity

/**
 * Created by lingchen on 2020/5/5. 16:46
 * mail:lingchen52@foxmail.com
 */
object ActivityCollector {

    private val activities = ArrayList<Activity>()

    fun addActivity(activity: Activity) {
        activities.add(activity)
    }

    fun removeActivity(activity: Activity) {
        activities.remove(activity)
    }

    fun finishAll() {
        for (activity in activities) {
            if (!activity.isFinishing) {
                activity.finish()
            }
        }
        activities.clear()
        //终结进程
        android.os.Process.killProcess(android.os.Process.myPid())
    }
}